import Image
import matplotlib
import pdb


def imROC(im1, im2, cropBox=None):
    """
    This function will generate a ROC curve when given 2 image patches.  
    The assumptions made are:
    1. The data is 8 bits with the range [0 255]
    2. There are three color planes

    Algorithm.  The basic idea is to take two histograms and to determine the probablity of 
    will do an integration as we go along for simplicity 
    just use 2 memory variables a rolling sum and a total size

    Threshold value is the index

    In parallel could do a vector approach
    """
    if cropBox!=None:
        im1 = im1.crop(cropBox)
        im2 = im2.crop(cropBox)

    red1, green1, blue1 = im1.split()
    red2, green2, blue2 = im2.split()


    red1Hist=red1.histogram()
    green1Hist=green1.histogram()
    blue1Hist=blue1.histogram()

    red2Hist=red2.histogram()
    green2Hist=green2.histogram()
    blue2Hist=blue2.histogram()

    totalPixels1=im1.size[0]*im1.size[1];
    totalPixels2=im2.size[0]*im2.size[1];
    pdb.set_trace()